package com.situ.edu.service.impl;

import com.situ.edu.dao.IXiTeacherDao;
import com.situ.edu.dao.impl.XiTeacherDaoImpl;
import com.situ.edu.pojo.entity.Teacher;
import com.situ.edu.pojo.query.TeacherQuery;
import com.situ.edu.pojo.vo.TeacherVO;
import com.situ.edu.service.IXiTeacherService;
import com.situ.edu.util.PageInfo;

import java.util.List;

public class XiTeacherServiceImpl implements IXiTeacherService {
    private IXiTeacherDao teacherDao = new XiTeacherDaoImpl();

    @Override
    public PageInfo selectByPage(TeacherQuery teacherQuery) {
        List<TeacherVO> list = teacherDao.selectByPage(teacherQuery);
        int totalCount = teacherDao.selectTotalCount(teacherQuery);
        return PageInfo.ok(totalCount,list);
    }

    @Override
    public void add(Teacher teacher) {
        teacherDao.add(teacher);
    }

    @Override
    public void updateStatus(int id, int status) {
        teacherDao.updateStatus(id,status);
    }

    @Override
    public void deleteById(int id) {
        teacherDao.deleteById(id);
    }

    @Override
    public void deleteAll(String[] ids) {
        for (String id : ids) {
            teacherDao.deleteById(Integer.parseInt(id));
        }
    }

    @Override
    public Teacher selectById(int id) {
        return teacherDao.selectById(id);
    }

    @Override
    public void update(Teacher teacher) {
        teacherDao.update(teacher);
    }
}
